<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>Sifteo SDK: Sifteo::Random Struct Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="doxygen-style-overrides.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<center>
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Sifteo SDK" src="sdk_logo.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">v1.0.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
</center>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Home</span></a></li>
      <li><a href="pages.html"><span>Guides</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Reference</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>Sifteo</b></li><li class="navelem"><a class="el" href="struct_sifteo_1_1_random.html">Random</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="struct_sifteo_1_1_random-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">Sifteo::Random Struct Reference<div class="ingroups"><a class="el" href="group__math.html">Math</a></div></div>  </div>
</div><!--header-->
<div class="contents">

<p>Pseudo-random number generator.  
 <a href="struct_sifteo_1_1_random.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="math_8h_source.html">sifteo/math.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a8c20f367d7149068f21f9713286a03f7"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a8c20f367d7149068f21f9713286a03f7">chance</a> (float probability)</td></tr>
<tr class="memdesc:a8c20f367d7149068f21f9713286a03f7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Take a chance. Returns a boolean that has a 'probability' chance of being 'true'.  <a href="#a8c20f367d7149068f21f9713286a03f7">More...</a><br/></td></tr>
<tr class="separator:a8c20f367d7149068f21f9713286a03f7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af899b186b31ab887e47710e10fcc7ec4"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="af899b186b31ab887e47710e10fcc7ec4"></a>
float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#af899b186b31ab887e47710e10fcc7ec4">expovariate</a> (float averageInterval)</td></tr>
<tr class="memdesc:af899b186b31ab887e47710e10fcc7ec4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a generated pseudorandom inverval for a poisson process (e.g. whack-a-mole timing). <br/></td></tr>
<tr class="separator:af899b186b31ab887e47710e10fcc7ec4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a02940bde6f5e545ca65274304afcdc50"><td class="memTemplParams" colspan="2"><a class="anchor" id="a02940bde6f5e545ca65274304afcdc50"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:a02940bde6f5e545ca65274304afcdc50"><td class="memTemplItemLeft" align="right" valign="top">T&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a02940bde6f5e545ca65274304afcdc50">randint</a> (T a, T b)</td></tr>
<tr class="memdesc:a02940bde6f5e545ca65274304afcdc50"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a uniformly distributed random integer in the range [a, b], including both end points. <br/></td></tr>
<tr class="separator:a02940bde6f5e545ca65274304afcdc50"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3ff0ae4aea430fa1856f2c10b6f85020"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3ff0ae4aea430fa1856f2c10b6f85020"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a3ff0ae4aea430fa1856f2c10b6f85020">Random</a> ()</td></tr>
<tr class="memdesc:a3ff0ae4aea430fa1856f2c10b6f85020"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a new random number generator, using an arbitrary seed. <br/></td></tr>
<tr class="separator:a3ff0ae4aea430fa1856f2c10b6f85020"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acaaa4c3327679e28f65b5a84faa5276a"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="acaaa4c3327679e28f65b5a84faa5276a"></a>
&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#acaaa4c3327679e28f65b5a84faa5276a">Random</a> (uint32_t s)</td></tr>
<tr class="memdesc:acaaa4c3327679e28f65b5a84faa5276a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct a new random number generator with a well-defined seed. <br/></td></tr>
<tr class="separator:acaaa4c3327679e28f65b5a84faa5276a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3c11f56b8d0a2446823cd1d19128f0fd"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a3c11f56b8d0a2446823cd1d19128f0fd"></a>
float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a3c11f56b8d0a2446823cd1d19128f0fd">random</a> ()</td></tr>
<tr class="memdesc:a3c11f56b8d0a2446823cd1d19128f0fd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a uniformly distributed floating point number between 0 and 1, inclusive. <br/></td></tr>
<tr class="separator:a3c11f56b8d0a2446823cd1d19128f0fd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20c4d97a91204a952582866d6d504b62"><td class="memTemplParams" colspan="2"><a class="anchor" id="a20c4d97a91204a952582866d6d504b62"></a>
template&lt;typename T &gt; </td></tr>
<tr class="memitem:a20c4d97a91204a952582866d6d504b62"><td class="memTemplItemLeft" align="right" valign="top">T&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a20c4d97a91204a952582866d6d504b62">randrange</a> (T a, T b)</td></tr>
<tr class="memdesc:a20c4d97a91204a952582866d6d504b62"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a uniformly distributed random integer in the half-open interval [a, b), including the lower but not the upper end point. <br/></td></tr>
<tr class="separator:a20c4d97a91204a952582866d6d504b62"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a47468c63e0617b037389be633d897178"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:a47468c63e0617b037389be633d897178"><td class="memTemplItemLeft" align="right" valign="top">T&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a47468c63e0617b037389be633d897178">randrange</a> (T count)</td></tr>
<tr class="memdesc:a47468c63e0617b037389be633d897178"><td class="mdescLeft">&#160;</td><td class="mdescRight">The one-argument variant of <a class="el" href="struct_sifteo_1_1_random.html#a20c4d97a91204a952582866d6d504b62" title="Returns a uniformly distributed random integer in the half-open interval [a, b), including the lower ...">randrange()</a> always starts at zero, and returns an integer up to but not including 'count'.  <a href="#a47468c63e0617b037389be633d897178">More...</a><br/></td></tr>
<tr class="separator:a47468c63e0617b037389be633d897178"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6add2fe2f365e20b0159291b6d4641f7"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a6add2fe2f365e20b0159291b6d4641f7"></a>
uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a6add2fe2f365e20b0159291b6d4641f7">raw</a> ()</td></tr>
<tr class="memdesc:a6add2fe2f365e20b0159291b6d4641f7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns the next raw 32-bit pseudo-random number. <br/></td></tr>
<tr class="separator:a6add2fe2f365e20b0159291b6d4641f7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1c837f44d0eb7d386897866c79a64570"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a1c837f44d0eb7d386897866c79a64570">seed</a> (uint32_t s)</td></tr>
<tr class="memdesc:a1c837f44d0eb7d386897866c79a64570"><td class="mdescLeft">&#160;</td><td class="mdescRight">Re-seed this random number generator.  <a href="#a1c837f44d0eb7d386897866c79a64570">More...</a><br/></td></tr>
<tr class="separator:a1c837f44d0eb7d386897866c79a64570"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9c725f02e64dff344afc1bb4b0bdd1c4"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a9c725f02e64dff344afc1bb4b0bdd1c4">seed</a> ()</td></tr>
<tr class="memdesc:a9c725f02e64dff344afc1bb4b0bdd1c4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Re-seed this random number generator arbitrarily.  <a href="#a9c725f02e64dff344afc1bb4b0bdd1c4">More...</a><br/></td></tr>
<tr class="separator:a9c725f02e64dff344afc1bb4b0bdd1c4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1af06331806ac52b38fb9c9a79c0271d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a1af06331806ac52b38fb9c9a79c0271d"></a>
float&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="struct_sifteo_1_1_random.html#a1af06331806ac52b38fb9c9a79c0271d">uniform</a> (float a, float b)</td></tr>
<tr class="memdesc:a1af06331806ac52b38fb9c9a79c0271d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a uniformly distributed floating point number in the range [a, b) or [a, b], depending on rounding. <br/></td></tr>
<tr class="separator:a1af06331806ac52b38fb9c9a79c0271d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Pseudo-random number generator. </p>
<p>Each instance of the <a class="el" href="struct_sifteo_1_1_random.html" title="Pseudo-random number generator.">Random</a> class has a distinct PRNG state.</p>
<p>When possible, method semantics here have been designed to match those used by Python's "random" module. </p>
</div><h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a8c20f367d7149068f21f9713286a03f7"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">bool Sifteo::Random::chance </td>
          <td>(</td>
          <td class="paramtype">float&#160;</td>
          <td class="paramname"><em>probability</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Take a chance. Returns a boolean that has a 'probability' chance of being 'true'. </p>
<p>If the argument is constant, all floating point math folds away at compile-time. For values of 0 and 1, we are guaranteed to always return false or true, respectively. </p>

</div>
</div>
<a class="anchor" id="a47468c63e0617b037389be633d897178"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">T Sifteo::Random::randrange </td>
          <td>(</td>
          <td class="paramtype">T&#160;</td>
          <td class="paramname"><em>count</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>The one-argument variant of <a class="el" href="struct_sifteo_1_1_random.html#a20c4d97a91204a952582866d6d504b62" title="Returns a uniformly distributed random integer in the half-open interval [a, b), including the lower ...">randrange()</a> always starts at zero, and returns an integer up to but not including 'count'. </p>
<p>Guaranteed to be capable of returning 'count' distinct values, starting at zero. </p>

</div>
</div>
<a class="anchor" id="a1c837f44d0eb7d386897866c79a64570"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Sifteo::Random::seed </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>s</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Re-seed this random number generator. </p>
<p>For a given seed, the subsequent random numbers are guaranteed to be deterministic. </p>

</div>
</div>
<a class="anchor" id="a9c725f02e64dff344afc1bb4b0bdd1c4"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void Sifteo::Random::seed </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Re-seed this random number generator arbitrarily. </p>
<p>This implementation uses the system's nanosecond timer. </p>

</div>
</div>
<hr/>The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="math_8h_source.html">math.h</a></li>
</ul>
</div><!-- contents -->
<!-- HTML footer for doxygen 1.8.3.1-->
<!-- start footer part -->
    <hr class="footer"/>
    <address class="footer">
        <p><a href="http://sifteo.com">Sifteo</a> SDK v1.0.0 <small>(see <a href="https://developers.sifteo.com/sifteosdk">all versions</a>)</small></p>
        <p>Last updated Wed Mar 27 2013, by <a href="http://www.stack.nl/~dimitri/doxygen">Doxygen</a></p>
    </address>
</body>
</html>
